<?php
namespace Home\Controller;
use Admin\Model\NewscateModel;
use Admin\Model\NewsModel;
use Admin\Model\PhotocateModel;
use Admin\Model\PhotoModel;
use Common\Model\CommonModel;
use Think\Controller;

class SunfundController extends Controller{

    public function index(){

        $newsModel=new NewsModel();
        $newscateModel=new NewscateModel();

        $data1['name']='阳光业务';
        $news_cate=$newscateModel->where($data1)->find()['id'];
        if(!empty($news_cate)){
            $arrNews=$newsModel->where('news_cate='.$news_cate)->field('title,abstract,layout as pic,create')->limit(1)->select();
            $arrNews=CommonModel::photo1($arrNews);
            $this->assign('arrNews',$arrNews);
        }

        //公司动态
        $data2['name']='爱心动态';
        $news_cate=$newscateModel->where($data2)->find()['id'];
        if(!empty($news_cate)){
            $arrNews1=$newsModel->where('news_cate='.$news_cate)->field('title,abstract,create')->order('`create` desc')->limit(5)->select();
            $arrNews1[0]['create']=date('Y-m-d',$arrNews1[0]['create']);
            $first=$arrNews1[0];
            if(!empty($first)){
                $this->assign('first',$first);
            }
            unset($arrNews1[0]);
            $arrNews1=CommonModel::status1($arrNews1);
            $this->assign('arrNews1',$arrNews1);
        }

        //轮播图
        $photocateModel=new PhotocateModel();
        $photoModel=new PhotoModel();
        $dat['name']='阳光基金';
        $photo_cate=$photocateModel->where($dat)->find()['id'];
        if(!empty($photo_cate)){
            $arrPhoto1=$photoModel->where('photo_cate='.$photo_cate)->field('pic,name')->select();
            $arrPhoto1=CommonModel::photo1($arrPhoto1);
            $this->assign('arrPhoto1',$arrPhoto1);
        }


        $this->display();
    }



}